package keyboard;

import java.util.HashMap;
import java.util.HashSet;

import dictionary.TireTree;

public class GroupCostCalculatorUsingScanning extends GroupCostCalculator {
	public GroupCostCalculatorUsingScanning(Keyboard keyboard, HashSet<Character> keysGroup, HashMap<Character, Float> keysValue, Position lastPosition) {
		super(keyboard, keysGroup, keysValue, lastPosition);
	}
	
	@Override
	public float GetTheCostOfPriority(int priority) {
		return priority + (priority - 1) / 4 * 2;
	}

	@Override
	public float GetExpectedCost() {
		float coverValue = 0f;
		char key = '?';
		for (char ch : keysGroup) {
			if (key == '?' || ch < key)
				key = ch;
		}
		
		for (char ch : TireTree.letterSet) {
			if (ch >= key)
				coverValue += keysValue.get(ch);
		}
		return coverValue + GetSelectingCost();
	}
}
